from django.shortcuts import render


# Create your views here.

class TplDemo:
    name = 'attr_name_value'

    def fun_demo(self):
        return 'fun_return_value'

    def tpl_list(self):
        return ['f_list_1', 'f_list_2']

    def delete(self):
        # to do 删除
        return 'delete done'

    delete.alters_data = True


def attr_demo(request):
    context_dict = {'person_name': 'Ten', 'indod': {'dict_key': 'dict_value'}, 'infoc': TplDemo()}
    return render(request, 'tpldemo/attr_demo.html', context_dict)


# def view1(request):
#     context = {'app':'My app', 'user':request.user, 'ip_address': request.META['REMOTE_ADDR'],
#          'message': 'I am the first View'}
#     return render(request, 'tpldemo/context_demo.html', context)
#
#
# def view2(request):
#     context = {'app':'My app', 'user':request.user, 'ip_address': request.META['REMOTE_ADDR'],
#          'message': 'I am the second View'}
#     return render(request, 'tpldemo/context_demo.html', context)

def custom_proc(request):
    return {'app': 'My app', 'user': request.user, 'ip_address': request.META['REMOTE_ADDR']}


# def view1(request):
#     context = {'proc': custom_proc(request),
#                'message': 'I am the first View'}
#     return render(request, 'tpldemo/context_demo.html', context)
#
#
# def view2(request):
#     context = {'proc': custom_proc(request),
#                'message': 'I am the second View'}
#     return render(request, 'tpldemo/context_demo.html', context)


def view1(request):
    context = {'message': 'I am the first View'}
    return render(request, 'tpldemo/context_demo.html', context)


def view2(request):
    context = {'message': 'I am the second View'}
    return render(request, 'tpldemo/context_demo.html', context)


def tag_demo(request):
    context = {'val': 'aaabbbcccAAABBBCCC', 'valint': 123456}
    return render(request, 'tpldemo/tag_demo.html', context)
